package net.peelmeagrape.hibernate.collections;

import net.peelmeagrape.hibernate.xmlgen.XmlElement;
import net.peelmeagrape.hibernate.xmlgen.XmlAttribute;
import net.peelmeagrape.hibernate.xmlgen.ChildElement;
import net.peelmeagrape.hibernate.xmlgen.DefaultFromGenericType;
import net.peelmeagrape.hibernate.Column;

import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Map collection element with value semantics. This is for simple value types. To
 * map objects, use {@link CompositeElement}.
 */
@Retention(RUNTIME)
@XmlElement(name="element")
public @interface H8Element
{
    @XmlAttribute String column() default "";
    @XmlAttribute String node() default "";
    @XmlAttribute String formula() default "";
    @XmlAttribute @DefaultFromGenericType(-1) String[] type() default {};
    @XmlAttribute int length() default 255;
    @XmlAttribute int precision() default -1;
    @XmlAttribute int scale() default -1;
    @XmlAttribute("not-null") boolean notNull() default false;
    @XmlAttribute boolean unique() default false;

    @ChildElement(1) Column[] columnMapping() default {};
}
